package com;

import com.pojo.User;
import com.util.JDBC;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        String sql="select * from user";
        Object[] objects=new Object[0];
        ResultSet query = JDBC.getQuery(sql, objects);
        List<User>  userList=new ArrayList<>();
        try{
            while(query.next()){
                User user=new User();
                user.setId(query.getInt(1));
                user.setName(query.getString(3));
                userList.add(user);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(userList.toString());
        String sql2="insert into user (name,age) value(?,?)";
        Object[] objects1=new Object[2];
        objects1[0]="abc";
        objects1[1]=18;
        int update = JDBC.getUpdate(sql2, objects1);
        if (update!=0){
            System.out.println("插入成功");
        }else{
            System.out.println("插入失败");
        }

    }
}
